//package com.example.demo.controller.Test;
//
//import com.example.demo.common.Result;
//import com.example.demo.pojo.User;
//import com.example.demo.service.UserService;
//import jakarta.servlet.http.HttpServletRequest;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RestController;
//
//
//import java.util.List;
//
//
//@RestController
//@Slf4j
////不用了,用jwt令牌
//public class SessionTestController {
//
//    //前端要写 axios.withCredentials=true;
//    @Autowired
//    private UserService userService;
//    @GetMapping  ("/loginAdmin111")
//    public Result selectUserAd(@RequestBody User user, HttpServletRequest request){
//        List<User> userList = userService.selectUser();
//        for (int i = 0; i < userList.size() ; i++){
//            if(userList.get(i).getAccount().equals(user.getAccount())){
//                if (userList.get(i).getPassword().equals(user.getPassword())){
//                    request.getSession().setAttribute("user",user.getAccount());//存给过滤器登录校验用的
//                    return Result.success();
//                }else{
//                    return Result.error("请输入正确的密码");
//                }
//            }
//        }
//
//        return Result.error("账户不存在");
//    }
//
////    @PostMapping("/login")
////    public Result login(@RequestBody User user){
////        log.info("员工登录:{}",emp);
////        Emp e = empService.login(emp);
////
////
////        //登录成功,生成令牌,下发令牌
////        if(e != null){
////            Map<String , Object> claims = new HashMap<>();
////            claims.put("id",e.getId());
////            claims.put("name",e.getName());
////            claims.put("username",e.getUsername());
////
////            String jwt = JwtUtils.generateJwt(claims);//jwt中包含了员工信息
////            return Result.success(jwt);//下发令牌//jwt令牌会存储在浏览器
////        }
////        return Result.error("用户名或密码错误");
////    }
//}
